﻿@using Library
@model IQueryable<Library.Models.ProductCategory>

@{
    ViewBag.Title = NOWCulture.GetString("Product categories");
    ViewBag.ActiveUrl = "admin/product-categories";
    Layout = "_Layout.cshtml";
}

<h2>@NOWCulture.GetString("Product categories")</h2>
<button type="button" class="btn btn-success" data-editor="create" data-id="-1"><span class="glyphicon glyphicon-plus"></span>@NOWCulture.GetString("Create new")</button>
@using (Ajax.BeginForm("SearchProductCategorys", "Admin",
    new AjaxOptions
    {
        HttpMethod = "GET",
        AllowCache = false,
        UpdateTargetId = "pc-tbody",
        InsertionMode = InsertionMode.Replace
    }, new { @id = "search-form", @class = "pull-right col-lg-6" }))
{
    <div class="input-group">
        <input type="text" name="keywords" class="form-control" placeholder="@NOWCulture.GetString("Search for...")">        
        <span class="input-group-btn">
            <button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span></button>
        </span>
    </div>
}
<div class="clearfix"></div>
<div class="table-responsive">
    <table class="table table-hover" id="product-categories">
        <thead>
            <tr>
                <th>@NOWCulture.GetString("Name")</th>
                <th>@NOWCulture.GetString("Description")</th>
                <th>&nbsp;</th>
            </tr>
        </thead>
        <tbody id="pc-tbody">
            @foreach (var productCategory in Model)
            {
                @Html.Partial("_ProductCategoryRow", productCategory)
            }
        </tbody>
    </table>
</div>
<div class="modal fade" id="editorModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="@NOWCulture.GetString("Close")"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title pull-left" id="modalLabel">@NOWCulture.GetString("Create new")/@NOWCulture.GetString("Edit") @NOWCulture.GetString("product category")</h4>
                <div class="pull-right langarea">
                    @foreach (var dic in NOWCulture.Dictionary)
                    {
                        var langName = NOWCulture.GetString(dic.Key.Name);
                        <button type="button" class="btn btn-default btn-xs" data-culture="@dic.Key.Id"><img src="~/Content/cultures/@dic.Key.Id/icon.png" alt="@langName" width="16" height="16" /> @langName</button>
                    }
                </div>
                <div class="clearfix"></div>
            </div>
            <div class="modalloading" id="editorModalLoading">
                <span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> @NOWCulture.GetString("Loading...")
            </div>
            <div id="formctnr"></div>
        </div>
    </div>
</div>
@Html.Action("ConfirmDialog", "Shared", new
{
    title = NOWCulture.GetString("Remove") + " " + NOWCulture.GetString("product category"),
    content = string.Format(NOWCulture.GetString("Are you sure you want to remove this {0}?"), NOWCulture.GetString("product category")),
    alertTitle = NOWCulture.GetString("Oh snap! You got an error!")
})
@section scripts
{
    <script> document.currentCulture = '@NOWCulture.CurrentCulture'; document.twoLetterISOLanguageName = '@NOWCulture.CurrentCultureInfo.TwoLetterISOLanguageName';</script>
    @(HttpContext.Current.IsDebuggingEnabled ? Scripts.Render("~/bundles/admin-product-categories") : Scripts.RenderFormat(@"<script src=""{0}"" async defer></script>", "~/bundles/admin-product-categories"))
}